#!/usr/bin/perl -w 
$str = "This is a test";
print "Enter a substring \n";
chomp ($substr = <STDIN>);
my $pos = -1;
while (1) {
my $ind = index ($str, $substr, $pos+1);
$pos = $ind;
 if ($ind == -1) {
 last;
 } else {
 print "Substring in position $ind \n";
 }
}
